package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.NursingLevel;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description NursingLevelServiceImpl
 * @Author xulang
 * @Date 2025-08-30
 */
@Service
public class NursingLevelServiceImpl implements NursingLevelService {

    @Autowired
    private NursingLevelMapper nursingLevelMapper;

    @Override
    public void getAllNursingLevel() {
        nursingLevelMapper.getAllNursingLevel();
    }

    @Override
    public void addNursingLevel(NursingLevelVo nursingLevelVo) {
        NursingLevel nursingLevel = BeanUtil.toBean(nursingLevelVo, NursingLevel.class);
        nursingLevelMapper.addNursingLevel(nursingLevel);
    }

    @Override
    public PageResponse<NursingLevelVo> getBypageNursingLevel(String name, Integer pageNum, Integer pageSize, Integer status) {
        PageHelper.startPage(pageNum,pageSize);
        Page<NursingLevelVo> nursingLevel=nursingLevelMapper.getBypageNursingLevel(name,status);
        PageResponse<NursingLevelVo> nursingLevelVoPageResponse = PageResponse.of(nursingLevel, NursingLevelVo.class);
        return nursingLevelVoPageResponse;
    }

    @Override
    public NursingLevelVo getNursingLevelById(Long id) {
        NursingLevel nursingLevel = nursingLevelMapper.getNursingLevelById(id);
        return BeanUtil.toBean(nursingLevel,NursingLevelVo.class);
    }

    @Override
    public void updateNursingLevel(NursingLevelVo nursingLevelVo) {
        NursingLevel nursingLevel=BeanUtil.toBean(nursingLevelVo,NursingLevel.class);
        nursingLevelMapper.updateNursingLevel(nursingLevel);
    }

    @Override
    public void deleteNursingLevel(Long id) {
        nursingLevelMapper.deleteNursingLevel(id);
    }

    @Override
    public void enableAndDisableNursingLevel(Long id, Integer status) {
        nursingLevelMapper.enableAndDisableNursingLevel(id,status);
    }
}
